package com.caineng.zhaobiao.zbapi.utils;

import lombok.Data;

import java.io.Serializable;

@Data
//@ApiModel("响应参数")
public class ResultApi implements Serializable {
	private static final long serialVersionUID = 1L;
//	@ApiModelProperty("0成功  1 失败")
	private int code;// 0成功1失败
//	@ApiModelProperty("消息内容")
	private String msg;
//	@ApiModelProperty("数据对象")
	private Object data;
//	@ApiModelProperty("总页数")
	private Integer totalPage;
//	@ApiModelProperty("总行数")
	private Long totalNum;

	private ResultApi(int code, String msg, Object data, Integer totalPage, Long totalNum) {
		this.code = code;
		this.msg = msg;
		this.data = data;
		this.totalPage = totalPage;
		this.totalNum = totalNum;
	}

	/**
	 * 返回的code是0
	 */
	public static ResultApi OK(String msg) {
		return new ResultApi(0, msg, null, null, null);
	}

	/**
	 * 返回的code是0
	 */
	public static ResultApi OK(String msg, Object data) {
		return new ResultApi(0, msg, data, null, null);
	}
	/**
	 * 返回的code是0
	 */
	public static ResultApi OK(String msg, Object data, Integer totalPage) {
		return new ResultApi(0, msg, data, totalPage, null);
	}
	/**
	 * 返回的code是0
	 */
	public static ResultApi OK(String msg, Object data, Integer totalPage, Long totalNum) {
		return new ResultApi(0, msg, data, totalPage, totalNum);
	}

	/**
	 * 返回的code是1
	 * @param msg
	 * @return
	 */
	public static ResultApi NO(String msg) {
		return new ResultApi(1, msg, null, null, null);
	}

	/**
	 * 返回的code是1
	 */
	public static ResultApi NO(String msg, Object data) {
		return new ResultApi(1, msg, data, null, null);
	}

	/**
	 * 返回的code是2,需要登录
	 */
	public static ResultApi NO2(String msg) {
		return new ResultApi(2, msg,  null,null, null);
	}

}
